package com.qk.management.mapper;

import com.qk.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 16778
 * @date 2025/10/7 11:55
 * @description
 */
@Mapper
public interface UserMapper {

    List<User> page(String name, Integer status, String phone, Integer deptId);

    void delete(List<Integer> ids);

    void insert(User user);

    @Select("select * from user where id = #{id}")
    User selectById(Integer id);

    @Update("update user set username = #{username},name = #{name},phone = #{phone},email = #{email},gender = #{gender}," +
            "status = #{status},dept_id = #{deptId},role_id = #{roleId},image = #{image},remark = #{remark},update_time = #{updateTime} where id = #{id}")
    void update(User user);

    @Select("select * from user")
    List<User> findALl();

    @Select("select u.* from user u left join role r on r.id = u.role_id where r.label = #{roleLabel}")
    List<User> selectByRoleLabel(String roleLabel);

    @Select("select * from user where dept_id = #{deptId}")
    List<User> selectByDeptId(Integer deptId);

    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);

    @Select("select image from user where image is not null and image != ''")
    List<String> selectImages();
}
